package com.example.administrator.yunniuusedcar.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.administrator.common.ui.BaseAdapterRV;
import com.example.administrator.common.ui.BaseHolderRV;
import com.example.administrator.yunniuusedcar.R;
import com.example.administrator.yunniuusedcar.activity.CommodityDetailsActivity;
import com.example.administrator.yunniuusedcar.adapter.baseadapter.BaseViewHolder;
import com.example.administrator.yunniuusedcar.adapter.baseadapter.SimpleAdapter;
import com.example.administrator.yunniuusedcar.bean.SelectCarData;
import com.example.administrator.yunniuusedcar.holder.PXxiaoLiangHolder;
import com.example.administrator.yunniuusedcar.model.mode_benn.PingXing_XiaoLiang_Bean;
import com.example.administrator.yunniuusedcar.ui.ShopDetailActivity;
import com.squareup.picasso.Picasso;

import java.util.List;

/**  平行进口 综合排序 适配器2
 * Created by USER2015 on 2017/12/23.  SimpleAdapter
 */

public class PingXing_XiaoLiangAdapter2 extends SimpleAdapter<PingXing_XiaoLiang_Bean> {

    private Context context;
    public PingXing_XiaoLiangAdapter2(Context context) {
        super(context,  R.layout.fragment_zonghepaixu);
        this.context = context;
    }

//    @Override
//    protected void convert(BaseViewHolder viewHoder, SelectCarData item) {
//        ImageView ivHomeCarPage = viewHoder.getImageView(R.id.iv_home_carPage);
//        TextView tvHomeCatInfo = viewHoder.getTextView(R.id.tv_home_catInfo);
//        TextView tvZGCarYhMoney = viewHoder.getTextView(R.id.tv_ZG_carYhMoney);
//        TextView tvHomeCarPay = viewHoder.getTextView(R.id.tv_home_carPay);
//        TextView itemHomeCarSCsave = viewHoder.getTextView(R.id.item_home_carSCsave);
//        TextView tvHomeCarMoney = viewHoder.getTextView(R.id.tv_home_carMoney);
//
//
//        Picasso.with(context).load(item.getLogo()).into(ivHomeCarPage);
//        tvHomeCatInfo.setText(item.getName());
//        tvZGCarYhMoney.setText(item.getIntegral_range());
//        tvHomeCarMoney.setText(item.getMarket_price());
//
//    }

    @Override
    protected void convert(BaseViewHolder viewHoder, PingXing_XiaoLiang_Bean item) {
        ImageView ivHomeCarPage = viewHoder.getImageView(R.id.iv_home_carPage);
        TextView tvHomeCatInfo = viewHoder.getTextView(R.id.tv_home_catInfo);
        TextView tvZGCarYhMoney = viewHoder.getTextView(R.id.tv_ZG_carYhMoney);
        TextView tvHomeCarPay = viewHoder.getTextView(R.id.tv_home_carPay);
        TextView itemHomeCarSCsave = viewHoder.getTextView(R.id.item_home_carSCsave);
        TextView tvHomeCarMoney = viewHoder.getTextView(R.id.tv_home_carMoney);


        Picasso.with(context).load(item.data.get(position).logo).into(ivHomeCarPage);
        tvHomeCatInfo.setText(item.data.get(position).name);
        tvZGCarYhMoney.setText(item.data.get(position).integral_range);
        tvHomeCarMoney.setText(item.data.get(position).market_price);
        itemHomeCarSCsave.setText("收藏:"+ item.data.get(position).collection_num);
        tvHomeCarPay.setText("付款:"+ item.data.get(position).sale);


        Intent intent = new Intent(context, CommodityDetailsActivity.class);    //商品详情
        intent.putExtra("RanCarid",item.data.get(position).car_id);
        context.startActivity(intent);
    }

//    public PingXing_XiaoLiangAdapter2(Context context, List<PingXing_XiaoLiang_Bean> listData) {
//        super(context, listData);
//    }
//
//    @Override
//    public BaseHolderRV<PingXing_XiaoLiang_Bean> createViewHolder(Context context, ViewGroup parent, int viewType) {
//        return new PXxiaoLiangHolder(context,parent,this);
//    }
}
